/* 
 * File:   VertexSet.hpp
 * Author: RaF
 *
 * Created on 29 novembre 2012, 10.07
 */

#ifndef VERTEXSET_HPP
#define	VERTEXSET_HPP

#include <map>
#include "Vertex.hpp"
class VertexSet {
public:
    VertexSet();
    ~VertexSet();
    void makeSet(int label);
    int find(int label);
    void unionSet(int label1,int label2);
    
private:
    std::map<int,int> *v_set;
    
    
};

 VertexSet::VertexSet(){
     this->v_set=new std::map<int,int>();
 }

 VertexSet::~VertexSet(){
     delete this->v_set;
 }
 void VertexSet::makeSet(int label){
     v_set->insert(std::pair<int,int>(label,v_set->size()));
 }
 
 int VertexSet::find(int label){
     return v_set->at(label);
 }
 
 void VertexSet::unionSet(int label1,int label2){
     int i1,i2;
     i1=find(label1);
     i2=find(label2);
     std::map<int,int>::iterator it;
     for(it=v_set->begin();it!=v_set->end();++it){
         if((*it).second == i1)
             (*it).second=i2;
     }
     
 }
#endif	/* VERTEXSET_HPP */

